package com.lc.demo.service.impl;

import com.lc.demo.bean.Admin;
import com.lc.demo.bean.Department;
import com.lc.demo.bean.Jwc;
import com.lc.demo.bean.Teacher;
import com.lc.demo.mapper.DepartmentMapper;
import com.lc.demo.mapper.JwcMapper;
import com.lc.demo.service.JwcService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: sakila
 * @Date: 2022/04/03/12:46
 * @Description:
 */
@Service
public class JwcServiceImpl  implements JwcService {

    @Autowired
    JwcMapper jwcMapper;


    @Autowired
    DepartmentMapper departmentMapper;

    @Override
    public Jwc login(String username, String password) {
        return    jwcMapper.login(username,password);
    }

    @Override
    public void addAdmin(Admin admin) {
        Integer departmentid = admin.getDepartmentid();
         Department department= departmentMapper.findById(departmentid);
        admin.setDepartmentname(department.getDepartmentname());
        jwcMapper.addAdmin(admin);
    }

    @Override
    public void deleteAdmin(Admin admin) {
        jwcMapper.deleteAdmin(admin);
    }

    @Override
    public void updateAdmin(Admin admin) {
        Integer departmentid = admin.getDepartmentid();
        Department byId = departmentMapper.findById(departmentid);
        admin.setDepartmentname(byId.getDepartmentname());
        jwcMapper.updateAdmin(admin);
    }

    @Override
    public List<Admin> getAdminList(Admin admin) {
        return jwcMapper.getAdminList(admin);
    }

    @Override
    public List<Teacher> getTeacherList(Teacher teacher) {
        return jwcMapper.getTeacherList(teacher);
    }

    @Override
    public void addDepartment(Department department) {
        departmentMapper.addDepartment(department);
    }

    @Override
    public void deleteDepartment(Department department) {
        departmentMapper.deleteDepartment(department);
    }

    @Override
    public void updateDepartment(Department department) {
        departmentMapper.updateDepartment(department);
    }

    @Override
    public List<Department> getDepartmentList(Department department) {
        return departmentMapper.getDepartmentList();
    }
}

